<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // 用户输入一个数，求和
    var n = parseInt(prompt('请输入一个数', '8'));
    var sum = 0;
    for (var i = 1; i <= n; i++) {
      sum += i;
    }
    //                     8        36
    alert('您输入的数字是' + n + '，它的累加和是' + sum);
  </script>
</body>

</html>